<?php
	include_once("card/CardConfig.php");
	
	/////////////////////////////////////////////////////////////////////////////////////////////////
	//                          Test Case
	/////////////////////////////////////////////////////////////////////////////////////////////////
	$cardState = initCardState();
	
	//////////////////////////////////////////////////////////////////////////
	//                          Test NumberCard
	//////////////////////////////////////////////////////////////////////////
	$card1 = new NumberCard(GREEN, 8);
	$card2 = new NumberCard(RED, 8);
	$card3 = new NumberCard(YELLOW, 5);
	
	if(!$card1->equal($cardState) && $card2->equal($cardState) && $card3->equal($cardState))
	{
		echo "NumberCard->equal() success<br>";
	}else{
		echo "NumberCard->equal() fail<br>";
	}
	
	$numCard = new NumberCard(GREEN, 5);
	$numCard->overlay($cardState);
	
	if($cardState->color == GREEN && $cardState->no == 5)
	{
		echo "NumberCard->overlay() success<br>";
	}else{
		echo "NumberCard->overlay() fail<br>";
	}
	
	//////////////////////////////////////////////////////////////////////////
	//                          Test StopCard
	//////////////////////////////////////////////////////////////////////////
	$cardState = initCardState();
	
	$card1 = new StopCard(RED);
	$card2 = new StopCard(GREEN);
	
	if($card1->equal($cardState) && !$card2->equal($cardState))
	{
		echo "StopCard->equal() success<br>";
	}else{
		echo "StopCard->equal() fail<br>";
	}
	
	$card2->overlay($cardState);
	if($cardState->color == GREEN && $cardState->step == 2)
	{
		echo "StopCard->overlay() success<br>";
	}else{
		echo "StopCard->overlay() fail<br>";
	}
	
	//////////////////////////////////////////////////////////////////////////
	//                          Test ReverseCard
	//////////////////////////////////////////////////////////////////////////
	$cardState = initCardState();
	
	$card1 = new ReverseCard(RED);
	$card2 = new ReverseCard(GREEN);
	
	if($card1->equal($cardState) && !$card2->equal($cardState))
	{
		echo "ReverseCard->equal() success<br>";
	}else{
		echo "ReverseCard->equal() fail<br>";
	}	
	
	$card2->overlay($cardState);
	if($cardState->color == GREEN && $cardState->direction == -1)
	{
		echo "ReverseCard->overlay() success<br>";
	}else{
		echo "ReverseCard->overlay() fail<br>";
	}
	
	//////////////////////////////////////////////////////////////////////////
	//                          Test WildCard
	//////////////////////////////////////////////////////////////////////////
	$cardState = initCardState();
	
	$card1 = new WildCard(GREEN);
	$card2 = new WildCard(RED);
	if($card1->equal($cardState) && $card2->equal($cardState))
	{
		echo "WildCard->equal() success<br>";
	}else{
		echo "WildCard->equal() fail<br>";
	}
	
	$card2->overlay($cardState);
	if($cardState->color == RED)
	{
		echo "WildCard->overlay() success<br>";
	}else{
		echo "WildCard->overlay() fail<br>";
	}	
	
	//////////////////////////////////////////////////////////////////////////
	//                          Test WildDrawCard
	//////////////////////////////////////////////////////////////////////////
	$cardState = initCardState();
	$card1 = new WildDrawCard();
	
	$card1->overlay($cardState);
	if($cardState->num == 4)
	{
		echo "WildDrawCard->overlay() success<br>";
	}else{
		echo "WildDrawCard->overlay() fail<br>";
	}
	
	//////////////////////////////////////////////////////////////////////////
	//                          Test Draw2Card
	//////////////////////////////////////////////////////////////////////////
	$cardState = initCardState();
	$card1 = new Draw2Card(RED);
	$card2 = new Draw2Card(GREEN);
	if($card1->equal($cardState) && !$card2->equal($cardState))
	{
		echo "Draw2Card->equal() success<br>";
	}else{
		echo "Draw2Card->equal() fail<br>";
	}
	$card1->overlay($cardState);
	$card2->overlay($cardState);
	if($cardState->num == 4 && $cardState->color == GREEN)
	{
		echo "Draw2Card->overlay() success<br>";
	}else{
		echo "Draw2Card->overlay() fail<br>";
	}
	
	
	function initCardState()
	{
		$cardState = new CardState();
		$cardState->color = RED;
		$cardState->no = 5;
		return $cardState;
	}
?>